package io.command;

import io.IIO;
import io.command.result.IOResult;
import io.command.result.IOIntResult;
import card.Cardset;

/**
 * Command of rating a landlord
 * 
 * 
 * @version 1.2.0
 */
public class PlayerLandlordRatingCommand extends IOCommand {

	private String playerName;
	private Cardset hand;

	public PlayerLandlordRatingCommand(IIO io, String playerName, Cardset hand) {
		super(io);
		this.playerName = playerName;
		this.hand = hand;
	}

	/**
	 * Command details
	 */
	@Override
	public IOResult execute() {

		int input = 0;

		do {
			io.println("Player " + playerName + " here is your hand:");
			io.print(hand);
			io.println("Would you like to be the landlord? \n"
					+ "Please input the 1, 2 or 3 point(s) for rating: ");

			try {
				input = Integer.parseInt(io.getNextInput());
			} catch (NumberFormatException c) {
				input = 0;
			}
		} while (input != 1 && input != 2 && input != 3);

		io.println();
		return new IOIntResult(input);
	}

}
